package car.action;

import java.util.ArrayList;

import org.springframework.beans.factory.annotation.Autowired;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import car.service.CarInfoService;
public class selectCar extends ActionSupport {
	private int p;
	private int count;
	ArrayList list=null;
	@Autowired
	private CarInfoService carInfoService;
	
	public String selectCar(){
		int r=4;
		//获取要显示的总页数
		count=carInfoService.getCount(r);
		if(p<=0){
		    p=1;
		}
		if(p>=count){
		   	p=count;
		}
		//获取第p页的r行汽车数据
		list=(ArrayList)carInfoService.carInfoPage(p, r);
		if(list.size()>0){
			return SUCCESS;
		}else{
			return ERROR;
		}
	}
	
	
	public int getP() {
		return p;
	}
	public void setP(int p) {
		this.p = p;
	}
	public int getCount() {
		return count;
	}
	public void setCount(int count) {
		this.count = count;
	}
	public CarInfoService getCarInfoService() {
		return carInfoService;
	}
	public void setCarInfoService(CarInfoService carInfoService) {
		this.carInfoService = carInfoService;
	}
	public ArrayList getList() {
		return list;
	}
	public void setList(ArrayList list) {
		this.list = list;
	}
}
